import { Matrix3 } from '../math/Matrix3'
import { Vector2 } from '../math/Vector2'
import { BasicStyle, BasicStyleType } from '../style/BasicStyle'
import { Object2D, Object2DType } from './Object2D'
import { crtPathByMatrix } from './ObjectUtils'
type TextAlign='start' | 'left' | 'center' | 'right' |'end';

type  ShapeType= Object2DType & {
	type: string
	offset?: Vector2
	size: Vector2
	style?: BasicStyleType	
}


class Shape2D extends Object2D {
	deleteable = true;
	offset: Vector2 = new Vector2()// 起笔的位置
	size: Vector2 = new Vector2(300, 150)
	style: BasicStyle = new BasicStyle()
	readonly isShape2D = true
	originChanged = false  ;

	constructor() {
		super()
	}

	/* 属性设置 */
	setOption(attr:any) {
   }

	/* 世界模型矩阵*偏移矩阵 */
	get moMatrix(): Matrix3 {
		const {
			offset: { x, y },
		} = this
		return this.worldMatrix.multiply(new Matrix3().makeTranslation(x, y))
	}

	/* 视图投影矩阵*世界模型矩阵*偏移矩阵  */
	get pvmoMatrix(): Matrix3 {
		const {
			offset: { x, y },
		} = this
		return this.pvmMatrix.multiply(new Matrix3().makeTranslation(x, y))
	}

	/* 绘图 */
	drawShape(ctx: CanvasRenderingContext2D) {
		
	}

	/* 绘制图像边界 */
	crtPath(ctx: CanvasRenderingContext2D, matrix = this.pvmoMatrix) {

		let  {width,height} =this.size ;
	
		crtPathByMatrix(ctx, [0, 0, width, 0, width, height, 0, height], matrix)
	}
}


export { Shape2D }
  